<?php

// application/controllers/TbladresseController.php

class TbladresseController extends Zend_Controller_Action {

    private $logger;

    public function init() {
        $this->view->headTitle('BBViande - Adresse');
        $this->logger = Zend_Registry::get('logger');
        $this->logger->info("Hello from TbladresseController");
    }

    public function indexAction() {
        $tbladresse = new Application_Model_TbladresseMapper();
        $this->view->entries = $tbladresse->fetchAll();
    }

    public function signAction() {
        $request = $this->getRequest();
        $form = new Application_Form_Tbladresse();

        if ($this->getRequest()->isPost()) {
            if ($form->isValid($request->getPost())) {
                $allValue = new Application_Model_Tbladresse($form->getValues());
                $mapper = new Application_Model_TbladresseMapper();
                $mapper->save($allValue);
                $this->logger->info(Zend_Debug::dump($allValue, $label = null, $echo = true));
                return $this->_helper->redirector('index');
            }
        }

        $this->view->form = $form;
    }

}
